moment=2;
f100=figure(village+moment*10)
set(0,'DefaultAxesColorOrder',[0 0 0],...
'DefaultAxesLineStyleOrder',':|--')
subplot(3,2,1)
title('$\sigma$ (lhs) / Group size (rhs)','Interpreter','latex','fontsize',20)
hold on
if moment==1
 %   plot(betavec,sigma_plot2m(:,:,village))
[ax,p1,p2]=plotyy(beta_plot(:,:,village),sigma_plot2m(:,:,village),beta_plot(:,2,village),vss_max_plot(2,:)+1)  ;
set(p1,'Linewidth',2.5)
set(p2,'Linewidth',2.5)
else
  %    plot(beta_plot(:,:,village),sigma_plot(:,:,devillage))
[ax,p1,p2]=plotyy(beta_plot(:,:,village),sigma_plot(:,:,village),beta_plot(:,2,village),vss_max_plot(2,:)+1)
set(p1,'Linewidth',2.5)
set(p2,'Linewidth',2.5,'Linestyle','-')
end

%xlim(ax(1),[0.5,1])
ylim(ax(2),[3,6])
hold off
 h1 = legend('$\sigma$, ID','$\sigma$, CD','Group size, CD');
 set(h1,'Location','NorthWest','Orientation','horizontal','Interpreter','latex','fontsize',12)
xlim(ax(1),[0.84,0.98])
xlim(ax(2),[0.84,0.98])
%ylim([0,12.5])
ylabel(ax(1),'$\sigma$','interpreter','latex','fontsize',20)
ylabel(ax(2),'Group size, CD','interpreter','latex','fontsize',20)
xlabel('$\delta$','interpreter','latex','fontsize',20);
subplot(3,2,2)
title('Goodness of fit','Interpreter','latex','fontsize',20)
hold on
if moment==1
plot(beta_plot(:,:,village),fit_plot2m(:,:,village),'LineWidth',2.5) ;
%[ax,p1,p2]=plotyy(beta_plot(:,:,village),fit_plot2m(:,1,village),beta_plot(:,:,village),fit_plot2m(:,2,village)) ;
else
plot(beta_plot(:,:,village),fit_plot(:,:,village),'LineWidth',2.5) ;
%[ax,p1,p2]=plotyy(beta_plot(:,:,village),fit_plot(:,1,village),beta_plot(:,:,village),fit_plot(:,2,village)) ;
end
%set(p1,'Linewidth',2.5,'LineStyle',':')
%set(p2,'Linewidth',2.5,'LineStyle','--')

hold off
xlabel('$\delta$','interpreter','latex','fontsize',20);
xlim([0.84,0.98])
subplot(3,2,3)
title('$\frac{Var_{dc}}{Var_{dy}}$','Interpreter','latex','fontsize',20)
hold on
if moment==1
plot(beta_plot(:,:,village),squeeze(moment_plot2m(:,1,:,village)),'LineWidth',2.5)
plot(beta_plot(:,:,village),squeeze(data_plot2m(:,1,:,village)),'-','LineWidth',2.5)
else
plot(beta_plot(:,:,village),squeeze(moment_plot(:,1,:,village)),'LineWidth',2.5)
plot(beta_plot(:,:,village),squeeze(data_plot(:,1,:,village)),'-','LineWidth',2.5)
end
xlim([0.84,0.98])
hold off
xlabel('$\delta$','interpreter','latex','fontsize',20);
xlim([0.84,0.98])
for k=2:4
subplot(3,2,2+k)
if k==2
title('$\beta_{dcdy}$','Interpreter','latex','fontsize',24)
elseif k==3
 title('$\frac{Var_{dc|dy>0}-Var_{dc|dy\leq 0}}{Var_{dy}}$','Interpreter','latex','fontsize',24)   
else
title('$\Delta \beta_{dcdy}$','Interpreter','latex','fontsize',24)
end
hold on
if moment==1
plot(beta_plot(:,:,village),squeeze(moment_plot2m(:,k,:,village)),'LineWidth',2.5)
plot(beta_plot(:,:,village),squeeze(data_plot2m(:,k,:,village)),'-','LineWidth',2.5)  
else
plot(beta_plot(:,:,village),squeeze(moment_plot(:,k,:,village)),'LineWidth',2.5)
plot(beta_plot(:,:,village),squeeze(data_plot(:,k,:,village)),'-','LineWidth',2.5)
end
hold off
xlim([0.84,0.98])
xlabel('$\delta$','interpreter','latex','fontsize',20);
end
   h1 = legend('Individual deviations','Coalitional Deviations','Data');
 set(h1,'FontSize',28,'Location','South','Orientation','horizontal','Interpreter','latex','fontsize',20,'Position',[0.3623 -0.003  0.3 0.06])
 set(f100,'PaperOrientation','landscape','PaperPosition',[-1 -1 33 23])
 picid=['moments_plot_vill_' num2str(village) '_mom_' num2str(moment*2) '.pdf']
   